package com.gs.weather.dao;

import com.gs.weather.dao.mapper.DisasterForecastMapper;
import com.gs.weather.entity.DisasterForecast;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class DisasterForecastDao {
    //private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    DisasterForecastMapper mapper;

    public Integer add(DisasterForecast disasterForecast) {
        try {
            mapper.add(disasterForecast);
            return disasterForecast.getId();
        } catch (Exception e) {
           // logger.info("DisasterForecastDao：add->{}", e.getMessage());
            return null;
        }
    }

    public boolean delete(int id) {
        try {
            mapper.delete(id);
            return true;
        } catch (Exception e) {
            //logger.info("DisasterForecastDao：delete失败->{}", e.getMessage());
            return false;
        }
    }

    public boolean update(DisasterForecast disasterForecast) {
        try {
            mapper.update(disasterForecast);
            return true;
        } catch (Exception e) {
           // logger.info("DisasterForecastDao：update->{}", e.getMessage());
            return false;
        }
    }

    public Double queryThreshold(String name) {
        try {
            return mapper.queryThreshold(name);
        } catch (Exception e) {
            //logger.info("DisasterForecastDao：query失败->{}", e.getMessage());
            return null;
        }
    }

    public List<DisasterForecast> queryAll() {
        try {
            return mapper.queryAll();
        } catch (Exception e) {
            //logger.info("DisasterForecastDao：queryAll失败->{}", e.getMessage());
            return null;
        }
    }
}
